home *** CD-ROM | disk | FTP | other *** search
/ VRML Browsing & Building Cyberspace / VRML - Browsing and Building Cyberspace.iso / examples / 23.wrl < prev    next >
Text File  |  1995-06-29  |  1KB  |  54 lines

  1. #VRML V1.0 ascii
  2.  
  3. # Example Twenty-Three - A Cube defined with Coordinate3 and IndexedFaceSet
  4.  
  5.     # Just like the name says, a green cube.
  6.     DEF Cube_Green Separator {
  7.  
  8.         # It's a nice bright green cube
  9.         Material {
  10.             diffuseColor 0.000000 1.000000 0.000000
  11.             ambientColor 0.000000 0.100000 0.000000
  12.         }
  13.  
  14.         # The Coordinate3 node gives a list of points.
  15.         # A cube has eight points.
  16.         # Here they are.
  17.         Coordinate3 {
  18.             point [
  19.                 1.0 -1.0 1.0,  # Point Zero
  20.                 1.0 -1.0 -1.0, # Point One
  21.                 -1.0 -1.0 -1.0, # Point Two
  22.                 -1.0 -1.0 1.0, # etc.
  23.                 1.0 1.0 -1.0,
  24.                 -1.0 1.0 -1.0,
  25.                 -1.0 1.0 1.0,
  26.                 1.0 1.0 1.0
  27.             ]
  28.         }
  29.  
  30.         # Each line defines a triangular polygon,
  31.         # By referencing points in the Coordinate3 node.
  32.         # A cube has six faces.
  33.         # But each face has two triangular polygons
  34.         # So here's twelve polygons which define the cube.
  35.         IndexedFaceSet {
  36.             coordIndex [
  37.                 2, 1, 0, -1, # Polygon composed of Point 2, Point 1, Point 0
  38.                 2, 0, 3, -1, # Polygon composed of Point 2, Point 0, Point 3
  39.                 4, 1, 2, -1, # etc.
  40.                 4, 2, 5, -1,
  41.                 5, 2, 3, -1,
  42.                 5, 3, 6, -1,
  43.                 6, 3, 0, -1,
  44.                 6, 0, 7, -1,
  45.                 4, 5, 6, -1,
  46.                 4, 6, 7, -1,
  47.                 1, 4, 7, -1,
  48.                 1, 7, 0, -1
  49.             ]
  50.         }
  51.     }
  52.  
  53.  
  54.